// https://leetcode.cn/problems/number-of-1-bits/description/?envType=study-plan-v2&envId=top-interview-150

class Solution {
public:
    int hammingWeight(int n) {
        int ans = 0;
        while (n) {
            ans += (n & 1);
            n >>= 1;
        }
        return ans;
    }
};